<?
	$sess = new Zend_Session_Namespace(CLU_NS);
?>
<?php 
 if(isset($this->viewParams['place']['metadata']))
 	$metadata = unserialize($this->viewParams['place']['metadata']);
 ?>
<script src="/public/library/hvn/captcha.redraw.js" type="text/javascript"></script>
<!-- <script src="/public/library/jquery/jquery.translate-1.3.7.min.js" type="text/javascript"></script>
 -->
<script type="text/javascript">
/*$(function() {
    $("#ratingButton").click(function(e){
        $.getJSON("/en/place/ajax/rate-place", 
         	{	id: <?= $this->viewParams['place']->article_id ?>, 
        	 	rating: $("#ratingSelect").val()}, 
		        function(json) {
		        	if(json.success)
			            $("#ratingMessage").html(
			                    "Thanks for rating, current rate: " + json.rating + 
			                    " for rating_count: " + json.rating_count + 
			                    " for id: "+ json.id + " average: " + json.average
			                    ); 
			         else
			         	$("#ratingMessage").html("Error: Rated");
		        });
		        return false;
  		 });
});
*/
</script>

<script type="text/javascript">  
$(function() {
    $("a[name^=place-name-edit]").click(function(e){
        id = this.name.split('-')[3];
        $("#place-name-form-" + id).toggle(); 
        return false; 
    });
    
    //the place name text box KeyPress event
    $("input[id^=place-name-text]").bind('keypress', function(e) {
        if (e.keyCode == 13) { //Enter
            $("#place-name-submit-" + id).click();
            return false;
        } 
    });
    
    //submit the new place name
    $("input[id^=place-name-submit]").click(function(e){
        newPlaceName = $("#place-name-text-" + id).val();
        $.getJSON("/en/place/ajax/update-place-name", {'id': id, 'name': newPlaceName},
            function(json) {
                if (json.success)
                {
                    $("#place-name-" + id).html(json.name);
                    $("#place-name-form-" + id).hide();
                }
                else
                    $("#place-name-error-" + id).show().html("Could not insert to DB");
            });
        return false;
    });
	
	var oriLang = '<?= $this->viewParams['oriLang']?>';
	var lang = '<?= $sess->viewLang?>';
    googleTranslate(oriLang, lang, 'chitiet_title', 'text');
});
</script>
               <div class="box"  style="background: #ffffff;">
                     <div class="chitiet_bar">
                         <div class="chitiet_bar_left"></div>
                         <div class="chitiet_bar_right"><?=t(167)?></div>
                       </div>
			        <?if(strpos($sess->userPermissions, "update place") || 
        			    (isset($this->viewParams['place']['poster_id']) && $sess->user == $this->viewParams['place']['poster_id'] && strpos($sess->userPermissions,"update own place"))
            		) :?>
						<div style="background:#ffffff; text-align:right;  padding:0 6px;">
						<a href="<?=$this->hvnUrl(array('module' => 'place', 'action' => 'edit'))?>?id=
							<?if(isset($this->viewParams['place']['id'])) :?><?=$this->viewParams['place']['id']?><?endif?>"><?=t(135)?></a>
						| <a href="<?=$this->hvnUrl(array('module' => 'place', 'action' => 'delete'))?>?id=
							<?if(isset($this->viewParams['place']['id'])) :?><?=$this->viewParams['place']['id']?><?endif?>"><?=t(31)?></a>	 
						| <a href="<?=$this->hvnUrl(array('module' => 'place', 'action' => 'add-new-article'))?>?place_id=
							<?if(isset($this->viewParams['place']['id'])):?><?=$this->viewParams['place']['id']?><?endif?>"><?=t(528)?></a> 
						</div>
					<?endif ?>	
					<div class="clear"></div>
					<?if(strpos($sess->userPermissions, "translate article")):?>
					<a href="<?=$this->hvnUrl(array('module' => 'article', 'action' => 'translate'))?>?id=
						<?if(isset($this->viewParams['place']['article_id'])):?><?=$this->viewParams['place']['article_id']?><?endif?>&to=en"><?=t(90)?></a>
					<?endif?>
					
           <div class="chitiet_content">
                     <div class="chitiet_title"><a href="#">&nbsp;&nbsp;
                     	<?if(isset($this->viewParams['place']['article_data']['article_title'])):?>
                     		<?= $this->viewParams['place']['article_data']['article_title']?>
                     	<?elseif(isset($this->viewParams['place']['name'])):?>
                     		<?= $this->viewParams['place']['name']?>
                     	<?endif?>
                     </a>
                     </div>
					<?
                 		/*  $userId = $this->viewParams['place']['poster_id'];
				    	$contentType = 'place';
				    	$id = $this->viewParams['place']['id'];
				    	$size = 'small';
				    	if (!$this->viewParams['place']['thumb'])
				    	{
				    		$ret = "<img src='/public/themes/prime/images/common/100x100_no_image.gif' />";
				    	}
				    	else
				    	{
					    	$url = $this->viewParams['place']['thumb'];
					    	$dir = APP_PATH.$url;
	                        	$smallImage = str_replace("/original/", "/small/", $dir);
								$ret = '<img src="'. $smallImage.'" style="width:100px;  height:100px;" />';     	
				    	}  */
				    	//$metadata = unserialize($this->viewParams['place']['metadata']);
                 	?>
                 	<!--  <div class="chitiet_img" ><?=$ret;?></div> -->
                 	<div>
					<div class="clear"></div>
					<span style='color:red;font-size:14px'> 
					<?if(isset($this->viewParams['errorMessage'])) :?><?=$this->viewParams['errorMessage']; ?><?endif?>&nbsp;&nbsp;
					</span>
					<div class="text">
					<? if (isset($this->viewParams['place']['article_data']['article_body'] )) :?> 
				    	<?=$this->viewParams['place']['article_data']['article_body'] ?>
				    	<?elseif(isset($this->viewParams['place']['desc'])):?>
				    	<?= $this->viewParams['place']['desc']?>
				    	<?endif ?>
					</div>
               <div class="clear"></div>
               <div class="chitiet_case">
                <?if(isset($this->viewParams['place']['article_data']['article_post_time'])) :?>
                <?$date_time = explode(' ', date("G:i:s j/n/Y",$this->viewParams['place']['article_data']['article_post_time']))?>
 				<?endif?>
                <?=t(136)?> <a href="<?=$this->hvnUrl(array("module" => "user", "controller" => "account", "action" => "view"), "generic") ?>?id=
 									<?if(isset($this->viewParams['place']['poster_id'])):?><?=$this->viewParams['place']['poster_id'] ?><?endif?>"> 
 							<?if(isset($metadata['poster_name'])) :?><?=$metadata['poster_name'] ?><?endif?></a>&nbsp;&nbsp;<?if(isset($date_time)) :?><?=t(3007)?> <?=$date_time[0]?>,&nbsp; <?=t(20)?> <?=$date_time[1]?><?endif?>
 							               
               </div>
              <div class="clear"></div> 
               </div>
               <div class="clear"></div> 
                <?   if( !isset($this->viewParams["view_city"])):?>
               
             <div class="blog_news" style="height:auto;" align="left">
             <div class="blog_news_left"><?=t(777)?> :  <span class="chitiet_info">
             <?//=die_a($this->viewParams['place'])?>
             	<?=$this->viewParams['place']['address9'];?> <?=$this->viewParams['place']['address8'];?> <?=$this->viewParams['place']['address7'];?> 	
                <? if (isset($this->viewParams['place']['address6'] )) :?> 	    	
				<?= $this->viewParams['place']['address6']?>
				<?endif ?>
				<? if (isset($metadata['village_name'] )) :?>
				 <?= $metadata['village_name']?>,
				<?endif ?>
				<? if (isset($metadata['district_name'])) :?>
				 <?= $metadata['district_name']?>, 
				 <?endif ?>
				 <? if (isset($metadata['city_name'] )) :?>
				 <?= $metadata['city_name']?></span>
				 <?endif ?>
				 <br/>
				  <?=t(750)?> :  <?if(isset($this->viewParams['place']['phone'])):?><?= $this->viewParams['place']['phone']?><?endif?>
				  <br/>
				  <?=t(751)?> :   <?if(isset($this->viewParams['place']['fax'])):?><?= $this->viewParams['place']['fax']?><?endif?>
				 </div>
				 <div class="blog_news_right">
				 <?=t(779)?> : <span class="chitiet_info">
				<? if (isset($metadata['type_name'])) :?> 
				         <?= p($metadata['type_name'])?>,
				 <?endif ?>
				 <? if (isset($metadata['rtype_name'])) :?> 
				         <?= p($metadata['rtype_name'])?>
				 <?endif ?>
				  </span>
				 </div>
				 <div class="clear"></div>
				 </div>
				 <? endif ?>
						 
						 
						 
			 <div class="clear"></div>
            </div></div>
            <div class="clear"></div>